Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-language-service-utils

Package Overview
Dependencies
Maintainers
4
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service-utils

Utilities to support the GraphQL Language Service

  • 0.1.14
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is graphql-language-service-utils?

The graphql-language-service-utils package provides utility functions for working with GraphQL language services. It includes features for parsing, validating, and formatting GraphQL queries, as well as for handling GraphQL schema and documents.

What are graphql-language-service-utils's main functionalities?

parseGraphQL

This feature allows you to parse a GraphQL query string into an Abstract Syntax Tree (AST). The code sample demonstrates how to parse a simple GraphQL query.

const { parse } = require('graphql-language-service-utils');
const query = `query { user(id: 1) { name } }`;
const parsedQuery = parse(query);
console.log(parsedQuery);

validateGraphQL

This feature allows you to validate a GraphQL query against a given schema. The code sample demonstrates how to validate a simple GraphQL query using a schema.

const { validate } = require('graphql-language-service-utils');
const { buildSchema } = require('graphql');
const schema = buildSchema(`type Query { user(id: ID!): User } type User { id: ID! name: String }`);
const query = `query { user(id: 1) { name } }`;
const errors = validate(schema, parse(query));
console.log(errors);

formatError

This feature allows you to format GraphQL errors in a standardized way. The code sample demonstrates how to format a simple error message.

const { formatError } = require('graphql-language-service-utils');
const error = new Error('Something went wrong');
const formattedError = formatError(error);
console.log(formattedError);

Other packages similar to graphql-language-service-utils

Keywords

FAQs

Package last updated on 29 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc